import React from 'react';
import { render } from 'react-dom';
import '../app.global.css';
import { AppContainer } from 'react-hot-loader';
import App from './components/App';
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import ReactDom from 'react-dom';
import { Provider } from 'mobx-react';
import * as stores from './stores';

import { BrowserRouter as Router } from 'react-router-dom';
renderHotModule(App)

if (module.hot) {
  module.hot.accept('./components/App', () => {
    const NextRoot = require('./components/App'); // eslint-disable-line global-require
    renderHotModule(NextRoot)

  });
}

function renderHotModule(RootElement) {
  render(
    <LocaleProvider locale={zhCN}>
      <AppContainer>
        <Provider {...stores}>
          <Router>
            <RootElement />
          </Router>
        </Provider>
      </AppContainer>
    </LocaleProvider>,
    document.getElementById('app')
  )
}
